﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZFine.Application.SystemManage;
using ZFine.Code;
using ZFine.Web;

namespace Logiv.WEB.Areas.Project.Controllers
{
    public class BaseController : Controller
    {
        private UserApp serverApp = new UserApp();
        private DutyApp duty = new DutyApp();
        public Log FileLog
        {
            get { return LogFactory.GetLogger(this.GetType().ToString()); }
        }
        [HttpGet]
        [HandlerAuthorize]
        public virtual ActionResult Index()
        {
            return View();
        }
        [HttpGet]
        [HandlerAuthorize]
        public virtual ActionResult Form()
        {
            return View();
        }
        [HttpGet]
        [HandlerAuthorize]
        public virtual ActionResult Details()
        {
            return View();
        }
        protected virtual ActionResult Success(string message)
        {
            return Content(new AjaxResult { state = ResultType.success.ToString(), message = message }.ToJson());
        }
        protected virtual ActionResult Success(string message, object data)
        {
            return Content(new AjaxResult { state = ResultType.success.ToString(), message = message, data = data }.ToJson());
        }
        protected virtual ActionResult Error(string message)
        {
            return Content(new AjaxResult { state = ResultType.error.ToString(), message = message }.ToJson());
        }
        protected virtual ActionResult Warn(string message)
        {
            return Content(new AjaxResult { state = ResultType.warning.ToString(), message = message }.ToJson());
        }

        protected string FindGangWei(string keyValue) //传用户id
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                var user = serverApp.GetForm(keyValue);
                if (user != null)
                {
                    var result = duty.GetForm(user.F_DutyId);
                    if (result != null)
                    {
                        return result.F_FullName;
                    }
                    else
                    {
                        return null;
                    }
                  
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }


    }
}